package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Rest;
import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.BatchShiftsDTO;
import com.hksj.Intelligentmanagement.dto.ShiftsDTO;
import com.hksj.Intelligentmanagement.dto.ShiftsSimpleDTO;
import com.hksj.Intelligentmanagement.service.ShiftsService;
import com.hksj.Intelligentmanagement.vo.ShiftsSimpleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author zengke
 * @ClassName ShiftsController
 * @Date 2023/3/31 16:33
 * @Version 1.0
 */

@RestController
@Api(tags = "排班管理")
@RequestMapping("/api/shifts")
public class ShiftsController {

    @Autowired
    private ShiftsService shiftsService;

    @ApiOperation("进行排班")
    @PostMapping("/doShifts")
    public Result doShifts(@RequestBody ShiftsDTO shiftsDTO){
        return shiftsService.doShifts(shiftsDTO);
    }

    @ApiOperation("批量排班")
    @PostMapping("/batchShifts")
    public Result batchShifts(@RequestBody BatchShiftsDTO batchShiftsDTO){
        return shiftsService.batchShifts(batchShiftsDTO);
    }


    @ApiOperation("应用上一周的排班数据")
    @PostMapping("/useLastWeekShifts")
    public Result useLastWeekShifts(@RequestBody ShiftsDTO shiftsDTO){
        return shiftsService.useLastWeekShifts(shiftsDTO);
    }

    @ApiOperation("排班前移后移")
    @PostMapping("/moveShifts")
    public Result moveShifts(@RequestBody ShiftsDTO shiftsDTO){
        return shiftsService.moveShifts(shiftsDTO);
    }

    @ApiOperation("分页动态查询排班记录")
    @PostMapping("/queryShiftsListByPage")
    public Result queryShiftsListByPage(@RequestBody ShiftsDTO shiftsDTO){
        return Result.ok(shiftsService.queryShiftsListByPage(shiftsDTO));
    }

    @ApiOperation("每日排班 新增修改共用")
    @PostMapping("/saveShifts")
    public Rest saveShifts(@RequestBody ShiftsSimpleDTO shiftsDTO){
        shiftsService.saveShifts(shiftsDTO);
        return Rest.ok();
    }

    @ApiOperation("获取指定日期排班详情")
    @GetMapping("/getShifts")
    public Rest<ShiftsSimpleVo> getShifts(
        @ApiParam(value = "排班时间",required = true) @RequestParam String scheduleTime){
        ShiftsSimpleVo shiftsSimpleVo = shiftsService.getShifts(scheduleTime);
        return Rest.ok(shiftsSimpleVo);
    }

}
